<?php

use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;

class CreateSmsTable extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('sms', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('account', 100)->comment('账号');
            $table->unsignedTinyInteger('type')->default(1)->comment('账号类型|{"1":"手机号码","2":"邮箱"}');
            $table->text('message')->comment('信息内容');
            $table->string('sign')->comment('信息签名');
            $table->unsignedTinyInteger('status')->default(0)->comment('发送状态|["待发送","成功","失败"]');
            $table->dateTimeTz('send_at')->nullable()->comment('发送成功时间');
            $table->unsignedTinyInteger('sms_type')->default(1)->comment('短信类型|{"1":"验证码","2":"营销信息","3":"通知信息"}');
            $table->string('code', 10)->nullable()->comment('验证码');
            $table->unsignedTinyInteger('scene')->default(1)->comment('场景|{"1":"小程序登录","2":"身份证号码验证"}');
            $table->unsignedInteger('ip')->nullable()->comment('IP');
            $table->string('error_msg')->nullable()->comment('失败原因');
            $table->unsignedTinyInteger('is_verfication')->default(0)->comment('是否验证|["否","是"]');
            $table->unsignedBigInteger('app_id')->nullable()->comment('应用ID');
            $table->string('app', 50)->comment('应用');
            $table->timestamps();
            $table->comment('信息记录');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('sms');
    }
}
